package easy;

import java.util.HashMap;
import java.util.Map;

public class Solution_242 {

    public static boolean isAnagram(String s, String t) {
        if (s.equals(t)) return true;
        if (s.length()!=t.length()) return false;
        int[] arr = new int[26];
        int index;
        for (int i = 0; i < s.length(); i++) {
            index = s.charAt(i) - 'a';
            arr[index]++;

            index = t.charAt(i) - 'a';
            arr[index]--;
        }
        for (int count : arr) {
            if (count!=0) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(isAnagram("rat", "car"));
    }
}
